<template>
  <div class="admin-hospitals">
    <div class="dashboard-header">
      <h2>医院管理</h2>
      <div class="header-actions">
        <el-input
          v-model="searchQuery"
          placeholder="搜索医院"
          class="search-input"
          size="large"
        >
          <template #append>
            <el-button type="primary" icon="Search">搜索</el-button>
          </template>
        </el-input>
        <el-button type="primary" icon="Plus">添加医院</el-button>
      </div>
    </div>
    
    <el-table :data="hospitals" style="width: 100%" stripe>
      <el-table-column prop="id" label="ID" width="80" />
      <el-table-column prop="name" label="医院名称" width="200" />
      <el-table-column prop="address" label="地址" />
      <el-table-column prop="phone" label="联系电话" width="150" />
      <el-table-column prop="director" label="负责人" width="120" />
      <el-table-column prop="departments" label="科室数量" width="120" align="center">
        <template #default="scope">
          <el-tag type="info">{{ scope.row.departments }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="status" label="状态" width="100">
        <template #default="scope">
          <el-tag :type="scope.row.status === '启用' ? 'success' : 'danger'">
            {{ scope.row.status }}
          </el-tag>
        </template>
      </el-table-column>
      
      <el-table-column label="操作" width="180" align="center">
        <template #default="scope">
          <el-button 
            type="primary" 
            size="small" 
            icon="Edit"
            @click="editHospital(scope.row)"
          ></el-button>
          <el-button 
            type="danger" 
            size="small" 
            icon="Delete"
            @click="deleteHospital(scope.row)"
          ></el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <div class="pagination">
      <el-pagination
        v-model:current-page="currentPage"
        :page-size="pageSize"
        :total="total"
        layout="prev, pager, next, jumper, sizes, total"
        background
      />
    </div>
  </div>
</template>

<script>
import { ref } from 'vue'

export default {
  setup() {
    const searchQuery = ref('')
    const currentPage = ref(1)
    const pageSize = ref(10)
    const total = ref(50)
    
    const hospitals = ref([
      { id: 1, name: '市中心医院', address: '人民路100号', phone: '021-12345678', director: '张院长', departments: 12, status: '启用' },
      { id: 2, name: '人民医院', address: '中山路200号', phone: '021-87654321', director: '李院长', departments: 8, status: '启用' },
      { id: 3, name: '中医院', address: '文化路300号', phone: '021-56781234', director: '王院长', departments: 10, status: '禁用' }
    ])
    
    const editHospital = (hospital) => console.log('编辑医院:', hospital)
    const deleteHospital = (hospital) => console.log('删除医院:', hospital)
    
    return {
      searchQuery,
      currentPage,
      pageSize,
      total,
      hospitals,
      editHospital,
      deleteHospital
    }
  }
}
</script>

<style scoped>
.admin-hospitals {
  padding: 20px;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.search-input {
  width: 300px;
}

.pagination {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}
</style>